package com.sitanyun.merchant.guide.presenter.impl;

import com.sitanyun.merchant.guide.model.impl.SmsLoginAModelImpl;
import com.sitanyun.merchant.guide.model.inter.ISmsLoginAModel;
import com.sitanyun.merchant.guide.presenter.callback.CallBack;
import com.sitanyun.merchant.guide.presenter.inter.ISmsLoginAPresenter;
import com.sitanyun.merchant.guide.view.inter.ISmsLoginAView;

public class SmsLoginAPresenterImpl implements ISmsLoginAPresenter {
    private ISmsLoginAView mISmsLoginAView;
    private ISmsLoginAModel mISmsLoginAModel;

    public SmsLoginAPresenterImpl(ISmsLoginAView aISmsLoginAView) {
        mISmsLoginAView = aISmsLoginAView;
        mISmsLoginAModel = new SmsLoginAModelImpl();
    }

    @Override
    public  void getsmslogin(String mobile, String type) {
        mISmsLoginAModel.setsmslogin(mobile, type, new CallBack() {
            @Override
            public void onSuccess(Object response) {
                mISmsLoginAView.response(response,mISmsLoginAView.RESPONSE_ONE);
            }

            @Override
            public void onError(Throwable t) {
                mISmsLoginAView.response(t,mISmsLoginAView.RESPONSE_TWO);
            }
        });
    }

    @Override
    public void getLogin(String phone, String password) {
        mISmsLoginAModel.setLoginpass(phone, password, new CallBack() {
            @Override
            public void onSuccess(Object response) {
                mISmsLoginAView.responselogin(response,mISmsLoginAView.RESPONSE_ONE);
            }

            @Override
            public void onError(Throwable t) {
                mISmsLoginAView.responselogin(t,mISmsLoginAView.RESPONSE_TWO);
            }
        });
    }
}
